﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/masAdmin.master" AutoEventWireup="true"
    CodeFile="OrderList.aspx.cs" Inherits="admin_OrderList" %>

<%@ Register Assembly="CommonTagTime" Namespace="CommonTagTime.PagerControl" TagPrefix="cc1" %>
<%@ Import Namespace="CommonTagTime" %>
<asp:Content ID="Content2" ContentPlaceHolderID="pagename" runat="Server">
    Order List
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="content" runat="Server">
    <link rel="stylesheet" type="text/css" media="all" href="../scripts/jscalendar-1.0/calendar-win2k-cold-1.css"
        title="win2k-cold-1" />
    <!-- main calendar program -->
    <script type="text/javascript" src="../scripts/jscalendar-1.0/calendar.js"></script>
    <!-- language for the calendar -->
    <script type="text/javascript" src="../scripts/jscalendar-1.0/lang/calendar-en.js"></script>
    <!-- the following script defines the Calendar.setup helper function, which makes
       adding a calendar a matter of 1 or 2 lines of code. -->
    <script type="text/javascript" src="../scripts/jscalendar-1.0/calendar-setup.js"></script>
    <div class="content-box-header">
        <h3>
            Search Box</h3>
    </div>
    <div class="content-box-content">
        <div id="tab1">
            <table class="table100">
                <tr>
                    <td style="width: 150px;" align="right">
                        Tracking Order:
                    </td>
                    <td style="width: 100px;">
                        <asp:TextBox ID="F_txtTrackingOrder" runat="server" Width="90px"></asp:TextBox>
                    </td>
                    <td style="width: 120px;" align="right">
                        Purchase Order:
                    </td>
                    <td style="width: 120px;">
                        <asp:TextBox ID="F_txtPurchaseOrder" runat="server" Width="110px"></asp:TextBox>
                    </td>
                    <td style="width: 80px;" align="right">
                        Khách hàng:
                    </td>
                    <td style="width: 170px;" align="left">
                        <asp:DropDownList ID="F_ddlCustomer" Width="170" runat="server">
                        </asp:DropDownList>
                    </td>
                    <td align="left">
                    </td>
                </tr>
                <tr>
                    <td style="width: 100px;" align="right">
                        Dự kiến giao hàng:
                    </td>
                    <td colspan="5" align="left">
                        <asp:TextBox ID="F_txtFromEndDate" Width="90px" runat="server"></asp:TextBox>
                        <input type="button" value="+" style="height: 21px; cursor: pointer;" id="selectFromDate" />
                        &nbsp;&nbsp;~&nbsp;&nbsp;
                        <asp:TextBox ID="F_txtToEndDate" Width="90px" runat="server"></asp:TextBox>
                        <input type="button" value="+" style="height: 21px; cursor: pointer;" id="selectToDate" />
                    </td>
                    <td align="left">
                    </td>
                </tr>
                <tr>
                    <td style="width: 100px;" align="right">
                    </td>
                    <td colspan="5" align="left">
                        <asp:Button ID="btnSearch" runat="server" Text="Search" CssClass="button" OnClick="btnSearch_Click" />
                        <asp:Button ID="btnReset" runat="server" Text="Reset" CssClass="button" OnClick="btnReset_Click" />
                    </td>
                    <td align="left">
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <div id="divGrid" class="box" runat="server">
        <div class="pagination right">
            <cc1:Pager ID="Pager2" runat="server" OnPageIndexChanging="Pager2_PageIndexChanging"
                OnPageSizeChanging="Pager2_PageSizeChanging" />
        </div>
        <div>
            <asp:Button ID="btnDelete" Text="Delete" runat="server" CssClass="button" OnClientClick="return CheckDelete();"
                OnClick="btnDelete_Click" />
            <asp:Button ID="btnAddNew" Text="Add New" runat="server" CssClass="button" OnClick="btnAddNew_Click" />
        </div>
        <asp:Repeater ID="rptData" runat="server" OnItemCommand="rptData_ItemCommand" OnItemDataBound="rptData_ItemDataBound">
            <HeaderTemplate>
                <table class="table100" border="0">
                    <thead>
                        <th class="gridCheckBoxColumHeader">
                            <input id="chkCheckAll" type="checkbox" onclick="CheckAll(this.checked)" />
                        </th>
                        <th class="gridNoColumHeader">
                            No.
                        </th>
                        <th class="align-left">
                            <asp:LinkButton ID="lbtnCustomer" runat="server" Text="Khách hàng" CommandName="SortOrder"
                                CommandArgument="CustomerId">
                            </asp:LinkButton>
                        </th>
                        <th class="align-left" style="width: 170px;">
                            <asp:LinkButton ID="lbtnTrackingOrder" runat="server" Text="Tracking Order" CommandName="SortOrder"
                                CommandArgument="TrackingOrder">
                            </asp:LinkButton>
                        </th>
                        <th class="align-left" style="width: 170px;">
                            <asp:LinkButton ID="lbtnPurchaseOrder" runat="server" Text="Purchase Order" CommandName="SortOrder"
                                CommandArgument="PurchaseOrder">
                            </asp:LinkButton>
                        </th>
                        <th class="align-left" style="width: 130px;">
                            <asp:LinkButton ID="lbtnFinishDate" runat="server" Text="Dự kiến giao hàng" CommandName="SortOrder"
                                CommandArgument="FinishDate">
                            </asp:LinkButton>
                        </th>
                        <th class="align-left" style="width: 100px;">
                            Code Detail
                        </th>
                        <th class="griActionColumHeader">
                            Action
                        </th>
                    </thead>
            </HeaderTemplate>
            <ItemTemplate>
                <tr id="trRow" runat="server">
                    <td align="center">
                        <input type="checkbox" name="chk_<%#Eval("OrderId") %>" id="chk_<%#Eval("OrderId") %>"
                            onclick="CheckItem('<%#Eval("OrderId") %>',this.checked);" />
                    </td>
                    <td align="center">
                        <%#Container.ItemIndex + 1%>
                    </td>
                    <td>
                        <asp:Literal ID="ltrCustomer" runat="server"></asp:Literal>
                    </td>
                    <td>
                        <a href="OrderDetail.aspx?OrderId=<%#Eval("OrderId") %>&<%=paraURL%>" class="detail">
                            <%#Eval("TrackingOrder")%></a>
                    </td>
                    <td>
                        <%#Eval("PurchaseOrder")%>
                    </td>
                    <td align="left">
                        <asp:Literal ID="ltrFinishDate" runat="server"></asp:Literal>
                    </td>
                    <td align="center">
                        <asp:Literal ID="ltrDetail" runat="server"></asp:Literal>
                    </td>
                    <td align="center">
                        <a href="OrderAdd.aspx?OrderId=<%#Eval("OrderId") %>&<%=paraURL%>">
                            <img src="/App_Themes/Admin/images/icons/pencil.png" alt="Edit" title="Edit" />
                        </a>
                        <asp:ImageButton ID="imbDelete" runat="server" ImageUrl="~/App_Themes/Admin/images/cross_circle.png"
                            CommandName="Delete" />
                    </td>
                </tr>
            </ItemTemplate>
            <FooterTemplate>
                </table>
            </FooterTemplate>
        </asp:Repeater>
        <div class="pagination">
            <cc1:Pager ID="Pager1" runat="server" OnPageIndexChanging="Pager2_PageIndexChanging"
                OnPageSizeChanging="Pager2_PageSizeChanging" />
        </div>
    </div>
    <input type="hidden" value="" runat="server" id="hidID" />
    <input type="hidden" value="" runat="server" id="hidIDSelect" />
    <div id="divEmplty" runat="server" visible="false">
    </div>
    <script type="text/javascript">
        Calendar.setup({
            inputField: '<%=F_txtFromEndDate.ClientID %>',     // id of the input field
            ifFormat: "%m/%d/%Y",      // format of the input field
            button: "selectFromDate",  // trigger for the calendar (button ID)
            align: "Tl",           // alignment (defaults to "Bl")
            singleClick: true
        });
        Calendar.setup({
            inputField: '<%=F_txtToEndDate.ClientID %>',     // id of the input field
            ifFormat: "%m/%d/%Y",      // format of the input field
            button: "selectToDate",  // trigger for the calendar (button ID)
            align: "Tl",           // alignment (defaults to "Bl")
            singleClick: true
        });
    </script>
    <!-- End .content-box-content -->
    <script type="text/javascript">

        function CheckAll(status) {
            var id = document.getElementById('<%=hidID.ClientID %>').value;
            var arr = new Array();
            arr = id.split(';');
            if (arr.length > 0) {
                for (var i = 0; i < arr.length; i++) {
                    if (document.getElementById('chk_' + arr[i].toString())) {
                        document.getElementById('chk_' + arr[i].toString()).checked = status;

                    }
                }

            }
            if (status) {
                document.getElementById('<%=hidIDSelect.ClientID %>').value = id;
            }
            else document.getElementById('<%=hidIDSelect.ClientID %>').value = '';

        }
        function CheckItem(id, status) {

            var idSelect = document.getElementById('<%=hidIDSelect.ClientID %>').value;
            if (status) {
                idSelect += id + ';';
            }
            else idSelect = idSelect.replace(id + ';', '');
            if (idSelect.length == document.getElementById('<%=hidID.ClientID %>').value.length) {
                document.getElementById('chkCheckAll').checked = true;
            }
            else
                document.getElementById('chkCheckAll').checked = false;
            document.getElementById('<%=hidIDSelect.ClientID %>').value = idSelect;

        }
        function ConfirmDelete() {
            var yes = confirm('<%=Resources.Resource.MSG_CONFIRM_DELETE %>');
            return yes;
        }
        function CheckDelete() {

            var id = document.getElementById('<%=hidIDSelect.ClientID %>').value;
            if (id == '') {
                alert('<%=Resources.Resource.MSG_REQUIRE_SELECT_ITEM %>');
                return false;
            }
            else return ConfirmDelete();
        }
    </script>
</asp:Content>
